﻿using System;
using System.Windows.Forms;
using DevExpress.Xpo;
using Zero.DataLayer;
using Zero.DataLayer.MAP;
using Zero.DataLayer.Repository;
using Zero.POCO;

namespace DevExpress.MailClient.Win.Forms.Data
{
    public partial class frmUploadData : DevExpress.XtraEditors.XtraForm
    {
        public frmUploadData()
        {
            InitializeComponent();
        }

        private OpenFileDialog openFile;
        private void btnFind_Click(object sender, EventArgs e)
        {
            openFile=new OpenFileDialog();
            openFile.InitialDirectory = "c:\\";
            openFile.RestoreDirectory = true;
            openFile.ShowDialog();
            tePath.Text = openFile.FileName;
        }
        private void btnCharger_Click(object sender, EventArgs e)
        {

            switch (cbDureeTv.SelectedIndex)
            {
                case 0 :
                {

                    var resultat = DonneesFactory.CreateDonnees(openFile.FileName, teLibelle.Text, new IndividuRepository(), new VagueRepository(), new SupportTvRepository(), new SupportRadioRepository(), new SupportPresseRepository(), int.Parse(cbDureeTv.Text), cbMois.SelectedIndex+1, cbAnneeVague.SelectedIndex+2000, deDateDebut.DateTime, int.Parse(cbNbJour.Text));
                    break;
                    
                }
                case 1:
                {
                    var resultat = DonneesFactory.CreateDonneesQuart(openFile.FileName, teLibelle.Text, new IndividuRepository(), new VagueRepository(), new SupportTvRepository(), new SupportRadioRepository(), new SupportPresseRepository(), int.Parse(cbDureeTv.Text), cbMois.SelectedIndex + 1, cbAnneeVague.SelectedIndex + 2000, deDateDebut.DateTime, int.Parse(cbNbJour.Text));
                    break;
                }
               
            }

            this.Close();
        
        }
    }
}